// Preference.cpp: implementation of the CSetting class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
//#include "LanguageTerminal.h"
#include "Setting.h"

//#include "XMLDOMAuxFunctions.h"

//#include "MainviewDirector.h"

//#include "crtdbg.h"
//#include "MemLeakDetector.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace config
{

CSetting* CSetting::m_pInstance = NULL;

CSetting::CSetting()
{
	//m_pXMLDocFunctions = NULL;
	//m_pXMLDocCurrentLangRes = NULL;	
}

CSetting::~CSetting()
{

}

CSetting* CSetting::GetInstance()
{
	if (m_pInstance == NULL)
		m_pInstance = new CSetting();

	return m_pInstance;
}

void CSetting::ReleaseInstance()
{
	if (m_pInstance != NULL)
	{
		//if (m_pInstance->m_pXMLDocFunctions)
		//	ReleaseXMLNode(m_pInstance->m_pXMLDocFunctions);

		delete m_pInstance;
		m_pInstance = NULL;
	}
}


// **********************************
CStatus* CStatus::m_pInstance = NULL;

CStatus::CStatus()
{
	m_blIsOnline = FALSE;
//	m_blExitFlag = false;
	m_blForceLogin = false;

	srand( (unsigned)time( NULL ) );
}

CStatus::~CStatus()
{

}

CStatus* CStatus::GetInstance()
{
	if (m_pInstance == NULL)
		m_pInstance = new CStatus();

	return m_pInstance;
}

void CStatus::ReleaseInstance()
{
	if (m_pInstance != NULL)
	{

		delete m_pInstance;
		m_pInstance = NULL;
	}
}

UINT CStatus::GetRandomRetryInterval()
{
	return (UINT)(
				(double)rand() / RAND_MAX 
				* (m_uiRetryInterval - m_uiRetryIntervalMin) 
				+ m_uiRetryIntervalMin
			);
}

UINT CStatus::GetRandomHeartBeatInterval()
{
	return (UINT)(
				(double)rand() / RAND_MAX 
				* (m_uiHeartBeatInterval - m_uiHeartBeatIntervalMin) 
				+ m_uiHeartBeatIntervalMin
			);
}

}
